<?php

namespace App\Admin\Actions\WithdrawAction;

use Encore\Admin\Actions\RowAction;
use Illuminate\Database\Eloquent\Model;
use App\Supports\Withdraw\WithdrawMoneyReturn;
use App\Services\ApplyGoldCoinWithdraw\ApproveGoldCoinWithdraw;

class ConfirmWithdraw extends RowAction
{
    public $name = '通过';
    
    public function handle(Model $model)
    {
	    if ($model->isPaid()) {
		    return $this->response()->error('仅待处理提现申请可通过');
	    }
	    
	    if ($model->status == 'pending') {
	    	
	    	 $model->update(['status' => 'paid']);
		   /* app(ApproveGoldCoinWithdraw::class, [
			    'withdraw' => $model
		    ])->approve();
		    */
		    return $this->response()->success('提现审核成功')->refresh();
		    
	    } else {
		    return $this->response()->error('仅待处理提现申请可通过');
	    }
    }
}
